package psn.kiko.service.business.message;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.JmsException;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.stereotype.Service;
import psn.kiko.excepion.BaseBusinessException;

/**
 *消息队列服务
 */
@Service
public class MessageQueueService{
	@Autowired
	JmsTemplate jmsTemplate;
	
	/**
	 * 往默认topic/queue发布文本消息
	 * */
	public void publishTextMessage(String textMassage){
		try{
			jmsTemplate.send(session->session.createTextMessage(textMassage));
		}catch(JmsException e){
			e.printStackTrace();
			throw new BaseBusinessException(e.getMessage());
		}
	}
}
